/*
 * @Description:
 * @Author: maxyang
 * @Date: 2022-05-16 20:04:41
 * @LastEditTime: 2022-08-10 16:36:29
 * @LastEditors: liutq
 * @Reference:
 */
package main

import (
	"fmt"
	"log"

	"github.com/gin-gonic/gin"
	"github.com/maxyang107/jinglan/aliyun"
	"github.com/maxyang107/jinglan/job"
	"github.com/maxyang107/jinglan/model"
	"github.com/maxyang107/jinglan/router"
	"gopkg.in/ini.v1"
)

func main() {
	conf, err := ini.Load("./env.ini")
	if err != nil {
		log.Fatal("配置文件读取失败, err = ", err)
	}

	_, err2 := aliyun.InitAliClient(conf)
	if err2 != nil {
		fmt.Println(err2.Error())
		return
	}

	r := gin.Default()

	//初始化客户端路由
	router.LoadClientRouter(r)

	//初始化后台路由
	router.LoadAdminRouter(r)

	// 初始化数据库
	db := model.InitDB(conf)
	defer db.Close()

	//初始化redis
	model.InitRedis()
	//初始化任务
	job.DealOrderExpertime()

	r.Run(":8099")

}
